package com.example.demo.config;/**
 * @Auter 李孝在
 * @Date 2025/1/17
 */

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.Contact;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @projectName: demo
 * @package: com.example.demo.config
 * @className: asd
 * @author: Eric
 * @description: TODO
 * @date: 2025/1/17 22:47
 * @version: 1.0
 */
@Configuration
@EnableAutoConfiguration
@ConditionalOnProperty(name = "swagger.enable", matchIfMissing = true)
public class SwaggerConfiguration {

    @Bean
    public OpenAPI docsOpen2Api()
    {
        return new OpenAPI()
                .info(new Info()
                        .title("这是标题")
                        .description("这是介绍")
                        .termsOfService("https://www.baidu.com")
                        .version("版本")
                        .contact(new Contact().name("作者姓名"))
                )
                .externalDocs(new ExternalDocumentation()
                        .description("接口有问题?点这里!")
                        .url("https://baidu.com/"));
    }

    //分组
    @Bean
    public GroupedOpenApi fileApi()
    {
        return GroupedOpenApi.builder().group("文件上传").pathsToMatch("/file/**").build();
    }
    @Bean
    public GroupedOpenApi testApi()
    {
        return GroupedOpenApi.builder().group("测试").pathsToMatch("/body/**").build();
    }
}
